{extend name='public/base' /}

{block name="content" }
<style type="text/css">
html {
    background-color: #fff !important;
}
	table {
		border-collapse: collapse;
		text-align: center;
		min-width: 600px;
	}

	table td {
		border: 0.5px solid #f1f0f0;
		color: #000000;
		height: 30px;
		font-size: 13px;
	}

	table th {
		border: 0.5px solid #f1f0f0;
		color: #000000;
		height: 30px;
		font-weight: 600;
		font-size: 15px;
	}


	table thead th {
		width: 100px;
	}

	.tianjia {
		color: #ffffff;
		font-size: 14px;
		background-color: #2d8cf0;
		padding: 3px;
		width: 80px;
		border-radius: 5px;
		text-align: center;
		line-height: 24px;
		display: inline-block;
		float: right;
	}

	.yes {
		color: #ffffff;
		font-size: 14px;
		background-color: #2d8cf0;
		padding: 3px;
		width: 60px;
		border-radius: 5px;
		text-align: center;
		line-height: 24px;
		display: inline-block;
		float: left;
		margin: 20px 0 20px 0;
	}

	.no {
		color: #ffffff;
		font-size: 14px;
		background-color: #2d8cf0;
		padding: 3px;
		width: 60px;
		border-radius: 5px;
		text-align: center;
		line-height: 24px;
		display: inline-block;
		float: right;
		margin: 20px 0 20px 0;
	}
</style>
<body>
	<form>
		<div style="width: 600px;line-height: 50px;font-weight: 600;font-size: 15px;">退费项目：</div>
		<table class="table">
			<thead>
				<tr style=" background-color: #f7f7f7;">
					<th>ID</th>
					<th>项目名称</th>
					<th>收费类型</th>
					<th>金额</th>
					<th>退费金额</th>
				</tr>
			</thead>
			{volist name="arr" id="t"}
			<tr>
				<td>{$t.id}
				<td>{$t.name}</td>
				<td>{$t.type}</td>
				<td>{$t.z_money}</td>
				<td style="color: #adadad;">{$t.z_money}</td>
			</tr>
			{/volist}
		</table>
		<div style="width: 600px; text-align: right;margin: 20px 0;font-size: 14px;"><input type="checkbox" value="1"
				id="checkbox">全部冲入商户余额</div>
		<div style="width: 600px; text-align: right;font-size: 14px;">实退合计（元）：<span>{$total}</span></div>
		<div style="font-size: 15px;">备注：<input type="text" name="" id="rmkVal" value="" placeholder="请输入备注"
				style="outline:none;outline: none; height: 26px;width: 240px;border-radius: 8px;border: 0.5px #ccc solid;" />
		</div>
		<div style="width: 210px;margin: 0 0 0 194px;">
			<span class="yes" lay-filter="refund" lay-submit="">确认</span>
			<span class="no" lay-filter="exit" lay-submit="">取消</span>
		</div>
		</div>
	</form>
	{/block}
	<!-- var id  = "{$id}" -->

	{block name="js"}
	<!--js处理区-->
	<script>
		// let aaa = document.getElementById('aaa')
		// aaa.onclick = () => {
		// 	window.history.back(-1);
		// 	console.log("aaaa")
		// }
		layui.use(['element', 'table', 'form', 'jquery', 'lucky', 'opTable', 'layer'], function() {
			var element = layui.element;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			var lucky = layui.lucky;
			var opTable = layui.opTable;
			var layer = layui.layer;
			form.render();
			console.log('进来了1')

			let remarkVal = ' '

			$(function() {
				$("#rmkVal").on("input", function(e) {
					remarkVal = e.delegateTarget.value
					console.log(e.delegateTarget.value,'e.delegateTarget.value')
				})
			});


			form.on('submit(refund)', function(obj) {
				console.log('进来了2')
				var id = "{$id}"
				var isCheckBox = 0;
				console.log(remarkVal,'remarkVal')
				$('input[type=checkbox]:checked').each(function() {
					isCheckBox = $(this).val()
				});
				$.ajax({
					url: "{:url('rebate')}",
					type: "post",
					data: {
						type: isCheckBox,
						id: id,
						remark: remarkVal
					},
					dataType: "json",
					success: function(data) {
						if (data.code == 1) {
							layer.msg(data.msg, {icon: 1,time: 1000},function(){
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							});
						} else {
							layer.msg(data.msg, {icon: 5,time: 1000},function(){
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							});
						}
					}
				});

			});
			form.on('submit(exit)', function(obj) {
				console.log('进来了3');
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			});

			/**
			 * 监听单行工具操作
			 */
		});
	</script>
	{/block}
